package com.demo15;

import java.io.*;

public class ConvertStreamDemo1 {
    public static void main(String[] args) throws IOException {
        //设置字符输出流文件
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("idea_demo\\java\\osw.txt"));
        //开始写入内容，写入字符串
        osw.write("人工智能");
        osw.close();

        //字符流读取数据效果
        InputStreamReader isr = new InputStreamReader(new FileInputStream("idea_demo\\java\\osw.txt"),"UTF-8");
        int chr;
        //循环判断
        while ((chr=isr.read())!=-1){
            System.out.print((char)chr);
        }
        //关闭
        isr.close();
    }
}
